﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;


namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class CTPhanQuyenBlo
    {
         #region "Khai báo các biến"
        private CTPhanQuyenDAO da;
        private CTPhanQuyenDTO _CTPQ;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTPhanQuyenDTO CTPQ
        {
            get { return _CTPQ; }
            set { _CTPQ = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public CTPhanQuyenBlo()
        {            
            da = new CTPhanQuyenDAO();
        }
        public bool InsertCTPQ(string MaNhom,string MaForm,bool Them,bool Xoa,bool Sua, bool ToanQuyen)
        {
            _CTPQ = new CTPhanQuyenDTO(MaNhom, MaForm, Them, Xoa, Sua,ToanQuyen);
            if (!da.InsertCTPhanQuyen(CTPQ))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTPQ(string MaNhom, string MaForm, bool Them, bool Xoa, bool Sua, bool ToanQuyen)
        {
            _CTPQ = new CTPhanQuyenDTO(MaNhom, MaForm, Them, Xoa, Sua, ToanQuyen);
            if (!da.UpdateCTPhanQuyen(CTPQ))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTPQ(string MaNhom, string MaForm)
        {
            if (!da.DeleteCTPhanQuyen(MaNhom,MaForm))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTPhanQuyen()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTPhanQuyen();
            return ds;
        }
        #endregion 
    }
}